package monitor;

import monitor.mbean.DomainRuntimeMBean;
import monitor.mbean.ThreadPoolRuntimeMBean;
import monitor.mbean.WebAppComponentRuntimeMBean;

public class WlsMonitor {

	public static void main(String[] args) throws Exception{
		
		DomainRuntimeMBean drmb = new DomainRuntimeMBean();
		System.out.println("Active connection current count : " + drmb.getActiveConnectionsCurrentCount());
		System.out.println("Current capacity : " + drmb.getCurrCapacity());
		System.out.println("Connection delay time : " + drmb.getConnectionDelayTime());
		
		ThreadPoolRuntimeMBean tprmb = new ThreadPoolRuntimeMBean();
		System.out.println("Execute Thread total count : " + tprmb.getExecuteThreadTotalCount());
		System.out.println("Execute thread : " + tprmb.getExecuteThreads());
	
		WebAppComponentRuntimeMBean wacrmb = new WebAppComponentRuntimeMBean();
		System.out.println("Open Session Current Count : " + wacrmb.getOpenSessionsCurrentCount());
		System.out.println("Open Session High Count : " + wacrmb.getOpenSessionsHighCount());

		
		
		
		
		/*
		 * 
		 */
		/*
		public static MBeanInfo getMbeanInfo(ObjectName objName) throws Exception{
			return connection.getMBeanInfo(objName);
		}
		
		public static MBeanAttributeInfo[] getMbeanAttributes(ObjectName objName)  throws Exception{
			return connection.getMBeanInfo(objName).getAttributes(); 
		}
		
		public static void test() {
			connection = Connector.getJmxConnection();
			String objName = "com.bea:Name=examplesServer_/examplesWebApp"
					+",ServerRuntime="
					+Conf.getConf("ServerRuntime")
					+",Location="
					+Conf.getConf("ServerRuntime")
					+",ApplicationRuntime=examplesWebApp"
					+",Type=WebAppComponentRuntime";
			
			try{
				MBeanAttributeInfo[] mbatif = getMbeanAttributes(new ObjectName(objName));

				for(int i=0; i < mbatif.length ; i++){
					
					System.out.println("mbatif " +i + " : " + mbatif[i].getType() );
					System.out.println("mbatif " +i + " : " + mbatif[i].getName() );
					System.out.println("mbatif " +i + " : " + mbatif[i].isReadable() );
					System.out.println("mbatif " +i + " : " + mbatif[i].isIs() );
				}
				//System.out.println( connection.getMBeanInfo(new ObjectName(objName)).getClassName() ) ;
				
				Connector.closeJmxConnection();
			}catch(Exception e){
				e.printStackTrace();
			}
			
			
		}
		
//		public static void 
		*/
	
	}

}